import db from "../utils/db"

export function login(data) {
  return db.user.where("name").equalsIgnoreCase(data.name).filter(item => item.password === data.password).toArray();
}

export function getInfo(name) {
  return db.user.where("name").equalsIgnoreCase(name).toArray();
}

export function getUserList() {

    return db.user.orderBy("id").filter(item => item.role !== "SUPPERADMIN").reverse().toArray();

}

export function addUser(data) {
  db.user.add({name: data.name, password: data.password, role: data.role, showName: data.showName});
}

export function deleteUser(id) {
  db.user.delete(id)
}

export function modifyUser(data) {
  db.user.put({id: data.id, name: data.name, password: data.password, role: data.role, showName: data.showName});
}
